package realdance.swing.jdbc;

import java.util.Scanner;

public class J26_SungJukService {
	Scanner sc = new Scanner(System.in);

		private static J26_SungJukDAO sjdao; 
		
		public J26_SungJukService(){
			sjdao = new J26_SungJukDAO();
		}
		public boolean createSungJuk(J26_SungJukVO sj){
			computeSungJuk(sj);
			return sjdao.insertSungJuk(sj);
			
	}
	// 총점, 평균, 학점 계산
	public void computeSungJuk(J26_SungJukVO sj){
		int tot = Integer.parseInt(sj.getKor())
				 + Integer.parseInt(sj.getEng())
				 + Integer.parseInt(sj.getMat());
				
		float avg = (float)tot/3;
		
		switch((int)avg/10){
		case 10: case 9: sj.setGrd("A");break;
		case 8: sj.setGrd("B");break;
		case 7: sj.setGrd("C");break;
		case 6: sj.setGrd("D");break;
		default : sj.setGrd("F");break;	
		}
		sj.setTot(tot + "");	
		sj.setAvg(avg + "");
		
	}
}
